//
//  MCChooseAreaModel.swift
//  StoreManage
//
//  Created by MC on 2018/9/20.
//  Copyright © 2018年 MC. All rights reserved.
//

import UIKit

class MCChooseAreaModel: NSObject {

    @objc var b : Bool = false
    
    @objc var proName : String = ""
    
    @objc var proId : NSNumber = 0
    
    
    
    
    // 当前cell的高度 跟该省下的所有城市有关
    @objc var allCitysHeight : CGFloat = 0
    // 所有选中的城市拼接的字符串
    @objc var allCitysStr : String = ""
    
    
    // 该省下面的所有城市
    @objc var allCityModels : [MCChooseAreaCityModel] = [MCChooseAreaCityModel]()
    @objc var citys : NSArray = NSArray() {
        didSet {
            let arrayM = NSMutableArray()
            for item in citys {
                
                
                let model = MCChooseAreaCityModel()
                model.setValuesForKeys(item as? [String:Any] ?? [:])
                
                allCitysStr += model.cityName
                allCitysStr += "  "
                
                arrayM.add(model)
            }
            
            allCitysHeight = allCitysStr.MCString_getHeight(font: MCFont(12), width: MCScreenWidth - 60) + 30

            allCityModels = arrayM as! [MCChooseAreaCityModel]
        }
    }

    
        
    
    
    // 当前cell的高度 跟选中的城市有关  默认高度是56
    @objc var selectedCitysHeight : CGFloat = 56
    // 所有选中的城市拼接的字符串
    @objc var selectedCitysStr : String = ""

    // 选中城市的集合
    @objc var selectedCityModels : [MCChooseAreaCityModel] = [MCChooseAreaCityModel]() {
        didSet {
            let arrayM = NSMutableArray()

            selectedCitysStr = ""

            if selectedCityModels.count == 0 {
                selectedCitysHeight = 56
            } else {
                for model in selectedCityModels {
                    selectedCitysStr += model.cityName
                    selectedCitysStr += " "
                    arrayM.add(model)
                }
                
                selectedCitysHeight = selectedCitysStr.MCString_getHeight(font: MCFont(12), width: MCScreenWidth - 70) + 56
            }
            
            selectedCityModels = arrayM as! [MCChooseAreaCityModel]
        }
    }
    
    
    
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
    }
}


class MCChooseAreaCityModel: NSObject {
    
    
    @objc var cityName : String = ""
    
    @objc var cityId : NSNumber = 0
    
    @objc var b : Bool = false

    
    @objc var areas : NSArray = NSArray()
    
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
    }
}
